package com.bos.controller;

import com.bos.dao.AlokasiPerSiswaDAO;
import com.bos.domain.AlokasiPerSiswa;
import com.bos.editor.AlokasiPerSiswaEditor;
import com.bos.util.enums.JenjangSekolah;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.Arrays;

/**
 * Created by IntelliJ IDEA.
 * User: Latief
 * Date: 3/17/11
 * Time: 8:29 PM
 * To change this template use File | Settings | File Templates.
 */
@Controller
public class AlokasiPerSiswaController {

    private AlokasiPerSiswaDAO alokasiPerSiswaDAO;

/* --------------------- Getter and Setter ---------------------*/

    @Autowired
    public void setAlokasiPerSiswaDAO(AlokasiPerSiswaDAO alokasiPerSiswaDAO) {
        this.alokasiPerSiswaDAO = alokasiPerSiswaDAO;
    }

/* -------------------------- Other Methods -------------------------- */

    @RequestMapping(value = "/alokasiPerSiswa", method = RequestMethod.GET)
    public String index(ModelMap modelMap) {
        modelMap.addAttribute("data", alokasiPerSiswaDAO.getAll());
        return "alokasiPerSiswa/index";
    }

    @RequestMapping(value = "/alokasiPerSiswa/{id}", method = RequestMethod.GET)
    public String show(ModelMap modelMap, @PathVariable("id") AlokasiPerSiswa alokasiPerSiswa) {
        modelMap.addAttribute("data", alokasiPerSiswa);
        modelMap.addAttribute("tab", "alokasiPerSiswa");

        return "alokasiPerSiswa/show";
    }

    @InitBinder
    protected void initBinder(WebDataBinder binder) throws Exception {
        binder.registerCustomEditor(AlokasiPerSiswa.class, new AlokasiPerSiswaEditor(alokasiPerSiswaDAO));
    }

}
